home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / djgpp / contrib / pdcurs22 / src / portable / addch.c next >
Encoding:
C/C++ Source or Header  |  1995-01-26  |  7.2 KB  |  199 lines

  1. /*
  2. ***************************************************************************
  3. * This file comprises part of PDCurses. PDCurses is Public Domain software.
  4. * You may use this code for whatever purposes you desire. This software
  5. * is provided AS IS with NO WARRANTY whatsoever.
  6. * Should this software be used in another application, an acknowledgement
  7. * that PDCurses code is used would be appreciated, but is not mandatory.
  8. *
  9. * Any changes which you make to this software which may improve or enhance
  10. * it, should be forwarded to the current maintainer for the benefit of 
  11. * other users.
  12. *
  13. * The only restriction placed on this code is that no distribution of
  14. * modified PDCurses code be made under the PDCurses name, by anyone
  15. * other than the current maintainer.
  16. * See the file maintain.er for details of the current maintainer.
  17. ***************************************************************************
  18. */
  19. #define    CURSES_LIBRARY    1
  20. #include <curses.h>
  21.  
  22. /* undefine any macros for functions defined in this module */
  23. #undef    addch
  24. #undef    waddch
  25. #undef    mvaddch
  26. #undef    mvwaddch
  27. #undef    echochar
  28. #undef    wechochar
  29.  
  30. /* undefine any macros for functions called by this module if in debug mode */
  31. #ifdef PDCDEBUG
  32. #  undef    refresh
  33. #  undef    wrefresh
  34. #  undef    move
  35. #  undef    wmove
  36. #endif
  37.  
  38. #ifdef PDCDEBUG
  39. char *rcsid_addch  = "$Id$";
  40. #endif
  41.  
  42. /*man-start*********************************************************************
  43.  
  44.   Name:                                                         addch
  45.  
  46.   Synopsis:
  47.       int addch(chtype ch);
  48.       int waddch(WINDOW *win, chtype ch);
  49.       int mvaddch(int y, int x, chtype ch);
  50.       int mvwaddch(WINDOW *win, int y, int x, chtype ch);
  51.       int echochar(chtype ch);
  52.       int wechochar(WINDOW *win, chtype ch);
  53.  
  54.   X/Open Description:
  55.      The routine addch() inserts the character ch into the default
  56.      window at the current cursor position and the window cursor is
  57.      advanced.  The character is of the type chtype as containing
  58.      both data and attributes.
  59.  
  60.      The routine waddch() inserts the character ch into the specified
  61.      window at the current cursor position.  The cursor position is
  62.      advanced.
  63.  
  64.      The routine mvaddch() moves the cursor to the specified (y, x)
  65.      position and inserts the character ch into the default window.
  66.      The cursor position is advanced after the character has been
  67.      inserted.
  68.  
  69.      The routine mvwaddch() moves the cursor to the specified (y, x)
  70.      position and inserts the character ch into the specified
  71.      window.  The cursor position is advanced after the character
  72.      has been inserted.
  73.  
  74.      The routine echochar() inserts the character ch into stdscr
  75.      at the current cursor position and a refresh() is called.  
  76.      The cursor position is advanced.
  77.  
  78.      The routine wechochar() inserts the character ch into the
  79.      specified window at the current cursor position and a wrefresh() 
  80.      is called. The cursor position is advanced.
  81.  
  82.      All these routines are similar to putchar().  The following
  83.      information applies to all the routines.
  84.  
  85.      If the cursor moves on to the right margin, an automatic
  86.      newline is performed.  If scrollok is enabled, and a character
  87.      is added to the bottom right corner of the screen, the
  88.      scrolling region will be scrolled up one line.  If scrolling
  89.      is not allowed, ERR will be returned.
  90.  
  91.      If ch is a tab, newline, or backspace, the cursor will be
  92.      moved appropriately within the window.  If ch is a newline,
  93.      the clrtoeol routine is called before the cursor is moved to
  94.      the beginning of the next line.  If newline mapping is off,
  95.      the cursor will be moved to the next line, but the x
  96.      coordinate will be unchanged.  If ch is a tab the cursor is
  97.      moved to the next tab position within the window.  If ch is
  98.      another control character, it will be drawn in the ^X
  99.      notation.  Calling the inch() routine after adding a control
  100.      character returns the representation of the control character,
  101.      not the control character.
  102.  
  103.      Video attributes can be combined with a character by ORing
  104.      them into the parameter.  This will result in these attributes
  105.      being set.  The intent here is that text, including
  106.      attributes, can be copied from one place to another using inch()
  107.      and addch().
  108.  
  109.      NOTE: All these functions are implemented as macros.
  110.  
  111.   PDCurses Description:
  112.      Depending upon the state of the raw character output, 7- or
  113.      8-bit characters will be output.
  114.  
  115.   X/Open Return Value:
  116.      All functions return OK on success and ERR on error.
  117.  
  118.   X/Open Errors:
  119.      No errors are defined for this function.
  120.  
  121.   Portability                             X/Open    BSD    SYS V
  122.                                           Dec '88
  123.       addch                                 Y        Y       Y
  124.       waddch                                Y        Y       Y
  125.       mvaddch                               Y        Y       Y
  126.       mvwaddch                              Y        Y       Y
  127.       echochar                              -        -      3.0
  128.       wechochar                             -        -      3.0
  129.  
  130. **man-end**********************************************************************/
  131.  
  132. /***********************************************************************/
  133. int    addch(chtype ch)
  134. /***********************************************************************/
  135. {
  136. #ifdef PDCDEBUG
  137.     if (trace_on) PDC_debug("addch() - called\n");
  138. #endif
  139.  
  140.     return( PDC_chadd( stdscr, ch, (bool)(!(_cursvar.raw_out)), TRUE ) );
  141. }
  142. /***********************************************************************/
  143. int    waddch(WINDOW *win, chtype ch)
  144. /***********************************************************************/
  145. {
  146. #ifdef PDCDEBUG
  147.     if (trace_on) PDC_debug("waddch() - called\n");
  148. #endif
  149.  
  150.     return( PDC_chadd( win, ch, (bool)(!(_cursvar.raw_out)), TRUE ) );
  151. }
  152. /***********************************************************************/
  153. int    mvaddch(int y, int x, chtype ch)
  154. /***********************************************************************/
  155. {
  156. #ifdef PDCDEBUG
  157.     if (trace_on) PDC_debug("mvaddch() - called\n");
  158. #endif
  159.     if (move(y,x) == ERR)
  160.         return(ERR);
  161.     return( PDC_chadd( stdscr, ch, (bool)(!(_cursvar.raw_out)), TRUE ) );
  162. }
  163. /***********************************************************************/
  164. int    mvwaddch(WINDOW *win, int y, int x, chtype ch)
  165. /***********************************************************************/
  166. {
  167. #ifdef PDCDEBUG
  168.     if (trace_on) PDC_debug("mvwaddch() - called\n");
  169. #endif
  170.     if (wmove(win,y,x) == ERR)
  171.         return(ERR);
  172.     return( PDC_chadd( win, ch, (bool)(!(_cursvar.raw_out)), TRUE ) );
  173. }
  174. /***********************************************************************/
  175. int    echochar(chtype ch)
  176. /***********************************************************************/
  177. {
  178. #ifdef PDCDEBUG
  179.     if (trace_on) PDC_debug("echochar() - called\n");
  180. #endif
  181.  
  182.     if (PDC_chadd( stdscr, ch, (bool)(!(_cursvar.raw_out)), TRUE ) == ERR)
  183.         return(ERR);
  184.     return(refresh());
  185. }
  186. /***********************************************************************/
  187. int    wechochar(WINDOW *win, chtype ch)
  188. /***********************************************************************/
  189. {
  190. #ifdef PDCDEBUG
  191.     if (trace_on) PDC_debug("wechochar() - called\n");
  192. #endif
  193.  
  194.     if (PDC_chadd( win, ch, (bool)(!(_cursvar.raw_out)), TRUE ) == ERR)
  195.         return(ERR);
  196.     return(wrefresh(win));
  197. }
  198.